


USE [AnotherSuccessfulProcedure]

IF EXISTS (SELECT * FROM sysobjects WHERE id = object_id(N'[dbo].[WeaponsSelectKillTop5ByWeaponName]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
BEGIN
	DROP PROCEDURE dbo.WeaponsSelectKillTop5ByWeaponName
END


SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		Neil Wilson
-- Create date: 09/03/08
-- Description:	Weapons Table Select - Top 5 killers per weapon
-- =============================================
CREATE PROCEDURE WeaponsSelectKillTop5ByWeaponName

            @WeaponName varchar(50)
	
AS

BEGIN

SELECT  TOP 5  PlayerName, count(killid) as [Kills], PlayerId FROM Kills
INNER JOIN PlayerNameList ON attacker_playerid = PlayerNameList.PlayerID
 where 
Attacker_Weaponid = (SELECT WeaponId FROM Weapons WHERE WeaponShortName = @WeaponName)
group by Attacker_PlayerId, PlayerName, PlayerId
order by [Kills] DESC

END
GO



--  WeaponsSelectKillTop5ByWeaponName 'tf_projectile_rocket'
